﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Enum;
@{
    ViewBag.Title = "人员信息";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";
    ItemListBox<User> list = ViewBag.UserList;
    List<Dormitory> dormitoryList = ViewBag.DormitoryList;
    GoodMan.Portal.Web.Areas.WorkSpace.Models.UserModel userModel = ViewBag.SearchModel;
}
    <link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>
        人员信息</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="/workspace/collegeadmin/UserInfoList" class="tip-bottom">人员管理</a>
    <a href="/workspace/collegeadmin/UserInfoList" class="current">信息列表</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <h5>
                        信息列表</h5>
                </div>
                <br />
                <form action="/workspace/collegeadmin/userinfolist" method="get" name="userForm">
                <div style="width: 95%; margin: 0px auto;">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr align="center">
                            <td width="3%">
                                楼栋
                            </td>
                            <td width="11%">
                                <select name="FloorId" id="FloorId" style="width: 150px;">
                                    <option value="-1" selected="selected">全部</option>
                                    @{
                                        if (dormitoryList != null && dormitoryList.Count != 0)
                                        {
                                            string selectedStr = string.Empty;
                                            foreach (var item in dormitoryList)
                                            {
                                                if (item.Id == userModel.FloorId) { selectedStr = "selected=\"selected\""; }
                                                else
                                                {
                                                    selectedStr = "";
                                                }
                                        <option value="@item.Id" @selectedStr>@item.Name</option>
                                            
                                            }
                                        }
                                    }
                                </select>
                            </td>
                            <td width="5%">
                                角色
                            </td>
                            <td width="11%">
                                <select name="SystemRole" id="SystemRole" style="width: 150px;">
                                    @{
                                        if (userModel.SystemRole == -1)
                                        {
                                        <option value="-1" selected="selected">全部</option>
                                        <option value="12">楼栋管理员</option>
                                        <option value="1">普通会员</option>
                                        }
                                        else if (userModel.SystemRole == 12)
                                        {
                                    
                                        <option value="-1">全部</option>
                                        <option value="12" selected="selected">楼栋管理员</option>
                                        <option value="1">普通会员</option>
                                        }
                                        else
                                        {
                                        <option value="-1">全部</option>
                                        <option value="12">楼栋管理员</option>
                                        <option value="1" selected="selected">普通会员</option>

                                        }
                                    }
                                </select>
                            </td>
                            <td width="5%">
                                性别
                            </td>
                            <td width="8%">
                                <select name="Gender" id="Gender" style="width: 80px;">
                                    @{
                                        if (userModel.Gender == -1)
                                        {
                                        <option value="-1" selected="selected">全部</option>
                                        <option value="1">男</option>
                                        <option value="0">女</option>
                                        }
                                        else if (userModel.Gender == 1)
                                        {
                                        <option value="-1">全部</option>
                                        <option value="1" selected="selected">男</option>
                                        <option value="0">女</option>
                                    
                                        }
                                        else
                                        {                                    
                                        <option value="-1">全部</option>
                                        <option value="1">男</option>
                                        <option value="0" selected="selected">女</option>
                                        }
                                    }
                                </select>
                            </td>
                            <td width="5%">
                                寝室号
                            </td>
                            <td width="10%">
                                <input type="text" placeholder="输入寝室号" name="Dormitory" value="@userModel.Dormitory" id="Dormitory" style="width: 120px" class="span4 " />
                            </td>
                            <td width="5%">
                                昵称
                            </td>
                            <td width="10%">
                                <input type="text" placeholder="输入昵称" name="NickName" value="@userModel.NickName" style="width: 120px" class="span4 " />
                            </td>
                            <td width="5%">
                                姓名
                            </td>
                            <td width="10%">
                                <input type="text" placeholder="输入真实姓名" name="RealName" value="@userModel.RealName" style="width: 120px" class="span4 " />
                            </td>
                            <td>
                                <button type="submit" class="btn btn-primary">
                                    查询</button>
                            </td>
                        </tr>
                    </table>
                </div>
                </form>
                <div class="widget-content nopadding">
                    <table class="table table-bordered data-table">
                        <thead>
                            <tr>
                                <th width="3%">
                                    序号
                                </th>
                                <th width="10%">
                                    用户名
                                </th>
                                <th width="10%">
                                    角色
                                </th>
                                <th width="10%">
                                    楼栋
                                </th>
                                <th width="5%">
                                    寝室号
                                </th>
                                <th width="5%">
                                    昵称
                                </th>
                                <th width="5%">
                                    真实姓名
                                </th>
                                <th width="10%">
                                    身份证号
                                </th>
                                <th width="5%">
                                    性别
                                </th>
                                <th width="10%">
                                    联系方式
                                </th>
                                <th width="5%">
                                    是否禁用
                                </th>
                                <th width="15%">
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @{
                                if (list != null && list.Data != null && list.Data.Count != 0)
                                {
                                    int index = 0;
                                    Dormitory dormitoryModel = new Dormitory();
                                    foreach (var item in list.Data)
                                    {
                                        index++;
                                        dormitoryModel = new Dormitory().Find(item.FloorId.ToString());
                                <tr class="gradeX">
                                    <td style="width: 10px;">@index
                                    </td>
                                    <td>
                                        <a href="/workspace/collegeadmin/UserInfo?u=@item.UserName" title="查看详细">@item.UserName</a>
                                    </td>
                                    <td>@item.SystemRole.Mapping()
                                    </td>
                                    <td>
                                        @{
                                        if (dormitoryModel != null)
                                        {
                                            <span>
                                                @dormitoryModel.Name
                                            </span>
                                        }
                                        else
                                        {
                                            <span>--</span>
                                        }
                                        }
                                    </td>
                                    <td>@item.Dormitory
                                    </td>
                                    <td>@item.NickName
                                    </td>
                                    <td>@item.RealName
                                    </td>
                                    <td>@item.IdCardNo
                                    </td>
                                    <td>@item.Gender.Mapping()
                                    </td>
                                    <td>
                                        <span title="QQ:@item.QQ " style="cursor:pointer">电话:@item.Phone</span>
                                    </td>
                                    <td class="center">
                                        @{if (!item.IsRefuse)
                                          {
                                            <a class="btn btn-success btn-mini" href="/workspace/collegeadmin/modifystatu?u=@item.UserName&page=@list.CurrentPage&s=1" title="点击禁用">
                                                正常</a>}
                                          else
                                          {
                                            <a class="btn btn-danger btn-mini" href="/workspace/collegeadmin/modifystatu?u=@item.UserName&page=@list.CurrentPage&s=0" title="点击启用">
                                                禁用</a>}}
                                    </td>
                                    <td class="center" style="min-width: 200px;">
                                        @{
                                          if (item.SystemRole==UserRole.Staff)
                                          {
                                            <a href="/workspace/collegeadmin/modifypassword?u=@item.UserName&page=@list.CurrentPage" class="btn btn-primary btn-mini">
                                                改密</a> <a href="/workspace/collegeadmin/modifyuser?u=@item.UserName&page=@list.CurrentPage" class="btn btn-primary btn-mini">
                                                    编辑</a> <a href="/workspace/collegeadmin/deluser?u=@item.UserName&page=@list.CurrentPage"  onclick="if (confirm('确认删除数据？删除后该数据无法恢复！')==true){return true;}else{return false;}"  class="btn btn-danger btn-mini">
                                                        删除</a>
                                          }
                                          else
                                          {
                                            <span>--</span>
                                          }
                                        }
                                    </td>
                                </tr>
                                    }

                                }
                                else
                                {
                                <tr>
                                    <td style="width: 10px;" colspan="10" align="center">
                                        <span>没有找到任何数据</span>
                                    </td>
                                </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
                @Html.Raw(list.PageItemSegment)
            </div>
        </div>
    </div>
</div>
@section tail{
    <script type="text/javascript" src="/scripts/select2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#likUser').addClass('open');
            $('#likUser').addClass('active');
            $('#FloorId').each(function () {
                $(this).select2();
            });
            $('#SystemRole').each(function () {
                $(this).select2();
            });
            $('#Gender').each(function () {
                $(this).select2();
            });
        });
    </script>
}
